import request from '@/utils/request'
const ProductProductServices = {
  actions: {
    /**
     * 商品分页
     */
    productPage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('product/page', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品新增
     */
    productSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('product/save', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品修改
     */
    productUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('product/update/' + params.id, {
          'orders': params.orders,
          'productInventoryNumber': params.productInventoryNumber,
          'productMarketPrice': params.productMarketPrice,
          'productShopPrice': params.productShopPrice,
          'productSn': params.productSn,
          'productCategoryId': params.productCategoryId,
          'productImg': params.productImg,
          'productName': params.productName,
          'productUnit': params.productUnit,
          'productLongDesc': params.productLongDesc
        }).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品删除
     */
    productRemove({ commit }, ids) {
      return new Promise((resolve, reject) => {
        request.post('product/remove', ids).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    }
  }
}
export default ProductProductServices
